<?php

namespace common\models;

use mivans\serialized\SerializedAttributes;
use Yii;

/**
 * This is the model class for table "{{%attribute}}".
 *
 * @property integer $id
 * @property integer $model_id
 * @property string $name
 * @property string $type
 * @property string $value
 * @property integer $filter
 * @property integer $order
 */
class Attribute extends \yii\db\ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%attribute}}';
    }

    public function behaviors()
    {
        return [
            [
                'class' => SerializedAttributes::className(),
                'attributes' => ['value'],
            ]
        ];
    }


    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['model_id', 'filter', 'order'], 'integer'],
            [['type'], 'string'],
            [['name'], 'string', 'max' => 50],
            [['value'], 'safe']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'model_id' => '关联模型id',
            'name' => '属性名称',
            'type' => '属性类型',
            'value' => '属性值',
            'filter' => '是否筛选',
            'order' => '排序',
        ];
    }
}
